package com.zjj.day0425.regex;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
import java.util.Scanner;

public class PhoneNumberVerification {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入手机号：");
        String phoneNumber = scanner.nextLine();
        scanner.close();

        if (phoneNumber.length() != 11) {
            System.out.println("输入的手机号位数不是 11 位，验证不通过。");
            return;
        }

        for (int i = 0; i < phoneNumber.length(); i++) {
            if (!Character.isDigit(phoneNumber.charAt(i))) {
                System.out.println("输入的手机号包含非数字字符，验证不通过。");
                return;
            }
        }

        char lastChar = phoneNumber.charAt(phoneNumber.length() - 1);
        if (phoneNumber.charAt(phoneNumber.length() - 2) == lastChar &&
                phoneNumber.charAt(phoneNumber.length() - 3) == lastChar) {
            System.out.println("输入的手机号是靓号，验证通过。");
        } else {
            System.out.println("输入的手机号验证通过，但不是靓号。");
        }
    }
}
